package vip.lsjscl.demo.custom;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import vip.lsjscl.demo.common.manager.ExportTaskManager;
import vip.lsjscl.demo.common.model.ExportProgress;

import java.util.HashMap;
import java.util.Map;

/**
 * 用户控制器
 *
 * @author zhangxingju
 * @date 2025/03/13
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/user")
public class UserController {

    private final UserDataProcessor processorService;


    /**
     * 2. 处理接口 - 处理数据并生成文件
     * 根据任务ID和处理器类型处理数据
     */
    @PostMapping("/process")
    public ResponseEntity<Map<String, Object>> processData(String taskId, @RequestBody Map<String, Object> params) {

        // 异步处理数据
        processorService.processData(taskId, params);

        Map<String, Object> result = new HashMap<>();
        result.put("taskId", taskId);
        result.put("status", "processing");
        result.put("message", "数据处理已开始");

        return ResponseEntity.ok(result);
    }
}
